<?php
namespace app\controller;

use app\BaseController;
use think\facade\Db;
use app\validate\Submit;

class Index extends BaseController
{

    public function index()
    {
        return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">16载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
    }
    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }
    public function cs(){
      //var_dump(importExcel());
//        $data = Db::table("students")->select();
//        $name = date('Y-m-d') . '人员列表信息';
//        $head = ['ID', '姓名', '性别','年龄','添加时间'];
//        //数据中对应的字段，用于读取相应数据：
//        $keys = ['id', 'name', 'sex','ago','create_time'];
//        exportExcel($name, $data, $head, $keys);
//        $size = 10485760;
//        $fileType = "jpg,jpeg";
//        $sc = fileUpload($size,$fileType);
//        var_dump($sc['path']);
//        echo out_poster('https://p0.ssl.img.360kuai.com/t01458a9b62b16af3e7.webp', 'https://ncstatic.clewm.net/feres/a44fa42f_4030f330_1651056214.png', 400, 400, 0, 0);
    }
    public function submit(){
        $data = $this->request->param();
        $submit = new Submit();
        if($submit->check($data)){
            $data['submit_time'] = date("Y-m-d H:i:s");
            $add = Db::table('submit')->insert($data);
            if($add){
                return json(['status'=>200,'msg'=>'提交成功']);
            }else{
                return json(['status'=>500,'msg'=>'提交失败']);
            }
        }else{
            return json(['status'=>500,'msg'=>$submit->getError()]);
        }
    }

}
